package com.example.myapplication.volunteerservice;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.myapplication.Config.Commom;
import com.example.myapplication.Config.OKHttpTool;
import com.example.myapplication.R;
import com.example.myapplication.ShuJu.RegistrationBean;

public class RegistrationActivity extends AppCompatActivity {

    private String registration_id;
    private ImageView but_lawyerList;
    private TextView score;
    private TextView name;
    private TextView playDate;
    private TextView likeNum;
    private TextView undertaker;
    private TextView detail;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_registration);
        initview();
        //返回
        img_bloak();
        //详情内容
        details();

    }

    private void details() {
        OKHttpTool.doNetRequest("prod-api/api/volunteer-service/activity/" + registration_id,
                OKHttpTool.GET,
                RegistrationBean.class,
                new OKHttpTool.NetCallback() {
                    @Override
                    public void onSuccess(Object obj) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                RegistrationBean registrationBean = (RegistrationBean)obj;
                                RegistrationBean.DataBean data = registrationBean.getData();
                                if(registrationBean.getCode()==200){
                                    name.setText(data.getTitle());
                                    score.setText("暂无");
                                    playDate.setText(data.getStartAt());
                                    undertaker.setText(data.getUndertaker());
                                    detail.setText(data.getDetail());
                                }
                            }
                        });
                    }

                    @Override
                    public void onFailure(String msg) {

                    }
                });
    }

    private void img_bloak() {
        but_lawyerList.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RegistrationActivity.this.finish();
            }
        });
    }

    private void initview() {
        Intent intent = getIntent();
        registration_id = intent.getStringExtra(Commom.REGISTRATION_ID);
        but_lawyerList = findViewById(R.id.but_lawyerList);

        name = findViewById(R.id.name);
        score = findViewById(R.id.score);
        playDate = findViewById(R.id.playDate);
        likeNum = findViewById(R.id.likeNum);
        undertaker = findViewById(R.id.undertaker);
        detail = findViewById(R.id.detail);
    }
}